package BJava2月.B综合练习;

public class L计算营业额 {
    public static void main(String[] args) {


    //创建二维数组
        int[][] yearArrArr = {
                {22, 66, 44},
                {77, 33, 88},
                {25, 45, 65},
                {11, 66, 99}
        };
           //表示全年的营业额
        int yearSum = 0;
       //2,遍历二维数组得到每一个一维数组
        for (int i = 0; i < yearArrArr.length; i++) {
            int[]quarterArr= yearArrArr[i];
            int sum = getSum(quarterArr);
            System.out.println("第"+(i+1) +"个季度的总营业额为：" + sum);
             yearSum = yearSum +sum;
        }
        System.out.println("全年的总营业额为：" + yearSum);


    }
    //定义一个方法，计算每一个季度的营业额
    public static int getSum(int[]arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum = sum + arr[i];
        }
        return sum;
    }
    }
